<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Gallery/classes/PhpFox_ComponentFeaturedPic.class.php, $Author:  $ */

/** Component for showing list of featured pics
 *
 * @version $Id: PhpFox_ComponentFeaturedPic.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 * @package module.gallery
 */
class PhpFox_Mod_Gallery_ComponentFeaturedPic extends BaseComponent
{
    function process()
    {
        $oGalleryItem = $this->_oModule->getItem('Gallery');
        /* @var $oGalleryItem PhpFox_Mod_Gallery_ItemGallery */
        $oGalleryService = $this->_oModule->getService('Gallery');
        /* @var $oGalleryService PhpFox_Mod_Gallery_ServiceGallery */
        $oSecurityService = App::getModuleService('Account', 'Security');
        /* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
        $oTpl = $this->_oModule->getTemplate();

        $oSecurityService->checkPerm('gallery', array('read_only', 'full'));
        $oSecurityService->checkAccess('gallery');

		$aItem = $this->oDatabase->getRow("SELECT id FROM `". App::geTT('main') ."` WHERE feature = '1' AND allow = '' AND who_view = '' ORDER BY RAND() LIMIT 0,1");

        if ( !count($aItem) || !isset($aItem['id']) )
        {
            $oTpl->assign(array(
                'bNo' => true,
            ));
            return $oTpl->fetch('FeaturedPic.html');
        }

        $oTpl->assign(array(
        	'sGImageUrl' => App::getParam('gallery.pic.url'),
        	'iId'        => $aItem['id'],
        ));
        return $oTpl->fetch('FeaturedPic.html');
    }
}
?>